import request from '@/utils/request'

// 子接口--获取子接口列表
export function getSubInterfaceArray (params) {
  var data = fromData(params)
  return request({
    url: 'sub_interface/getSubInterfaceArray',
    method: 'post',
    data
  })
}

// 子接口--添加子接口
export function addSubInterface (params) {
  var data = fromData(params)
  return request({
    url: 'sub_interface/addSubInterface',
    method: 'post',
    data
  })
}

// 子接口--获取子接口信息
export function getSubInterfaceInfo (params) {
  var data = fromData(params)
  return request({
    url: 'sub_interface/getSubInterfaceInfo',
    method: 'post',
    data
  })
}

// 子接口--删除子接口
export function del_sub_interface (params) {
  var data = fromData(params)
  return request({
    url: 'sub_interface/del_sub_interface',
    method: 'post',
    data
  })
}

// 子接口--编辑子接口
export function editSubInter (params) {
  var data = fromData(params)
  return request({
    url: 'sub_interface/editSubInter',
    method: 'post',
    data
  })
}


function fromData (params) {
  let formData = new FormData()
  for (const it in params) {
    if (!Object.is(params[it], null) && !Object.is(params[it], '')) {
      formData.append(it, params[it])
    }
  }
  return formData
}
